﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using CLibArtreve.bll;
using CLibArtreve.models;
using ULibArtreve.security;

namespace DrDynscriptWebApp._views._shared._components._security
{
    public partial class SingUp : System.Web.UI.UserControl
    {
        //WORDT NOG NIET GEBRUIKT

        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void linkSignUp_Click(object sender, EventArgs e)
        {
            if (this.Page.IsValid)
            {
                SignUp();
            }
        }

        //SIGN UP -> in BLL EN DAL ZITTEN DE CLASSEN (excluded, kijk dus in de mappen zelf)
        private void SignUp()
        {
            try
            {
                //1. BLL
                //-----------------------
                string connectionString = ConfigurationManager.ConnectionStrings["ARTREVEConnectionString"].ConnectionString;

                /*UserBLL bllUsers = new UserBLL();
                bllUsers.ConnectionString = connectionString;

                //SQLProfilesBLL bllProfiles = new SQLProfilesBLL();
                //bllProfiles.ConnectionString = connectionString;

                //2. INSERT USER
                //-----------------------
                User user = new User();
                user.Nickname = this.txtUserName.Text.Trim();
                user.Password = Crypto.ComputeHashMD5(this.txtPassword.Text.Trim());
                user.Email = this.txtEmail.Text.Trim();
                user.Activationdate = DateTime.Now;

                Int64? userId = bllUsers.InsertUser(user);                

                /*if (userId > 0)
                {
                    //3. INSER PROFILE
                    //-----------------------
                    Profile profile = new Profile();
                    profile.UserId = userId;
                    profile.FirstName = this.txtFirstName.Text.Trim();
                    profile.SurName = this.txtSurName.Text.Trim();

                    Int64? profileId = bllProfiles.InsertProfile(profile);
                }*/
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
    }
}